home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / DC.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  62KB  |  2,186 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.15  $
  6. //
  7. // Definition of GDI DC encapsulation classes:
  8. //   TDC, TWindowDC, TScreenDC, TDesktopDC, TClientDC, TPaintDC, TMetaFileDC,
  9. //   TCreatedDC, TIC, TMemoryDC, TDibDC, TPrintDC
  10. //----------------------------------------------------------------------------
  11. #if !defined(OWL_DC_H)
  12. #define OWL_DC_H
  13.  
  14. #if !defined(OWL_GDIBASE_H)
  15. # include <owl/gdibase.h>
  16. #endif
  17. #if defined(BI_PLAT_WIN16) && !defined(__PRINT_H)
  18. # include <print.h>      // Win16 printing and some general DC APIs
  19. #endif
  20.  
  21. #if defined(BI_NAMESPACE)
  22. namespace OWL {
  23. #endif
  24.  
  25. class _OWLCLASS TPen;
  26. class _OWLCLASS TBrush;
  27. class _OWLCLASS TFont;
  28. class _OWLCLASS TBitmap;
  29. class _OWLCLASS TPalette;
  30. class _OWLCLASS TIcon;
  31. class _OWLCLASS TCursor;
  32. class _OWLCLASS TDib;
  33. class _OWLCLASS TRegion;
  34. class _OWLCLASS TMetaFilePict;
  35. #if defined(BI_PLAT_WIN32)
  36. class _OWLCLASS TEnhMetaFilePict;
  37. #endif
  38.  
  39. // Win 32 object defines for 16 bit GetCurrentObject emulation
  40. //
  41. #if defined(BI_PLAT_WIN16)
  42. # define OBJ_PEN         1
  43. # define OBJ_BRUSH       2
  44. # define OBJ_PAL         5
  45. # define OBJ_FONT        6
  46. #endif
  47.  
  48. // Generic definitions/compiler options (eg. alignment) preceeding the 
  49. // definition of classes
  50. #include <services/preclass.h>
  51.  
  52. //
  53. // class TDC
  54. // ~~~~~ ~~~
  55. // Root class for GDI DC.  This class can be instantiated, or specialized
  56. // derived classes can be used to get specific behavior.
  57. //
  58. // Tracks & restores on destruction handles of first GDI objects that are
  59. // replaced by ::SelectObject()
  60. //
  61. // Can be used as an interface to a borrowed handle.
  62. //
  63. class _OWLCLASS TDC : private TGdiBase {
  64.   public:
  65.     // Constructors / destructor
  66.     //
  67.     TDC(HDC handle);  // use an existing DC, doesn't auto delete it
  68.     virtual    ~TDC();
  69.  
  70.     // Type Conversion Operators
  71.     //
  72.     operator    HDC() const;  // Must assume const is OK
  73.  
  74.     // Validation routine - used mainly for diagnostic purposes
  75.     //
  76.     bool        IsDC() const;
  77.  
  78.     // DC functions
  79.     //
  80.     bool         GetDCOrg(TPoint& point) const;
  81.     virtual int  SaveDC() const;
  82.     virtual bool RestoreDC(int savedDC = -1);
  83.     virtual int  GetDeviceCaps(int index) const;
  84.     virtual bool ResetDC(DEVMODE far& devMode);
  85.  
  86.     // Select GDI objects into this DC and restore them to original
  87.     //
  88.     void         SelectObject(const TBrush& brush);
  89.     void         SelectObject(const TPen& pen);
  90.     virtual void SelectObject(const TFont& font);
  91.     void         SelectObject(const TPalette& palette, bool forceBackground=false);
  92.     virtual void SelectStockObject(int index);
  93.     void         RestoreBrush();
  94.     void         RestorePen();
  95.     virtual void RestoreFont();
  96.     void         RestorePalette();
  97. #if defined(BI_PLAT_WIN32)
  98.     void         RestoreTextBrush();
  99. #endif
  100.     void         RestoreObjects();
  101.     HANDLE       GetCurrentObject(uint objectType) const;
  102.  
  103.     // Drawing tool functions
  104.     //
  105.     bool         GetBrushOrg(TPoint& point) const;
  106.     bool         SetBrushOrg(const TPoint& origin, TPoint far* oldOrg=0);
  107.     int          EnumObjects(uint objectType, GOBJENUMPROC proc, void far* data) const;
  108.  
  109.     // Color and palette functions
  110.     //
  111.     TColor       GetNearestColor(const TColor& color) const;
  112.     int          RealizePalette();
  113.     void         UpdateColors();
  114.     uint         GetSystemPaletteEntries(int start, int num,
  115.                                          PALETTEENTRY far* entries) const;
  116.     uint         GetSystemPaletteUse() const;
  117.     int          SetSystemPaletteUse(int usage);
  118.  
  119.     // Drawing attribute functions
  120.     //
  121.     TColor         GetBkColor() const;
  122.     virtual TColor SetBkColor(const TColor& color);
  123.     int          GetBkMode() const;
  124.     int          SetBkMode(int mode);
  125.     int          GetPolyFillMode() const;
  126.     int          SetPolyFillMode(int mode);
  127.     int          GetROP2() const;
  128.     int          SetROP2(int mode);
  129.     int          GetStretchBltMode() const;
  130.     int          SetStretchBltMode(int mode);
  131.     TColor         GetTextColor() const;
  132.     virtual TColor SetTextColor(const TColor& color);
  133.  
  134. #if defined(BI_PLAT_WIN32)
  135.     bool         SetMiterLimit(float newLimit, float* oldLimit=0);
  136. #endif
  137.  
  138.     // Viewport & window mapping functions
  139.     //
  140.     int          GetMapMode() const;
  141.     virtual int  SetMapMode(int mode);
  142.  
  143. #if defined(BI_PLAT_WIN32)
  144.     bool         SetWorldTransform(XFORM far& xform);
  145.     bool         ModifyWorldTransform(XFORM far& xform, uint32 mode);
  146. #endif
  147.  
  148.     bool         GetViewportOrg(TPoint& point) const;
  149.     TPoint       GetViewportOrg() const;
  150.     virtual bool SetViewportOrg(const TPoint& origin, TPoint far* oldOrg=0);
  151.     virtual bool OffsetViewportOrg(const TPoint& delta, TPoint far* oldOrg=0);
  152.  
  153.     bool         GetViewportExt(TSize& extent) const;
  154.     TSize        GetViewportExt() const;
  155.     virtual bool SetViewportExt(const TSize& extent, TSize far* oldExtent=0);
  156.     virtual bool ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom,
  157.                                   TSize far* oldExtent=0);
  158.  
  159.     bool         GetWindowOrg(TPoint& point) const;
  160.     TPoint       GetWindowOrg() const;
  161.     bool         SetWindowOrg(const TPoint& origin, TPoint far* oldOrg=0);
  162.     bool         OffsetWindowOrg(const TPoint& delta, TPoint far* oldOrg=0);
  163.  
  164.     bool         GetWindowExt(TSize& extent) const;
  165.     TSize        GetWindowExt() const;
  166.     virtual bool SetWindowExt(const TSize& extent, TSize far* oldExtent=0);
  167.     virtual bool ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom,
  168.                                 TSize far* oldExtent=0);
  169.  
  170.     // Coordinate functions
  171.     //
  172.     bool        DPtoLP(TPoint* points, int count = 1) const;
  173.     bool        DPtoLP(TRect& rect) const;
  174.     bool        LPtoDP(TPoint* points, int count = 1) const;
  175.     bool        LPtoDP(TRect& rect) const;
  176.  
  177.     // Clip & Update Rect & Rgn functions
  178.     //
  179.     int         GetClipBox(TRect& rect) const;
  180.     TRect       GetClipBox() const;
  181.     int         ExcludeClipRect(const TRect& rect);
  182.     int         ExcludeUpdateRgn(HWND wnd);
  183.     int         IntersectClipRect(const TRect& rect);
  184.     int         OffsetClipRgn(const TPoint& delta);
  185.     int         SelectClipRgn(const TRegion& region);
  186.     bool        PtVisible(const TPoint& point) const;
  187.     bool        RectVisible(const TRect& rect) const;
  188.     bool        GetBoundsRect(TRect& bounds, uint16 flags) const;
  189.     uint        SetBoundsRect(TRect& bounds, uint flags);
  190.     bool        GetClipRgn(TRegion& region) const;
  191.  
  192.     // MetaFile functions
  193.     //
  194.     int         EnumMetaFile(const TMetaFilePict& metaFile,
  195.                              MFENUMPROC callback, void far* data) const;
  196.     bool        PlayMetaFile(const TMetaFilePict& metaFile);
  197.     void        PlayMetaFileRecord(HANDLETABLE far& handletable,
  198.                                    METARECORD far& metaRecord, int count);
  199. #if defined(BI_PLAT_WIN32)
  200.     int         EnumEnhMetaFile(const TEnhMetaFilePict& metaFile,
  201.                                 ENHMFENUMPROC callback, void* data,
  202.                                 const TRect* rect) const;
  203.     bool        PlayEnhMetaFile(const TEnhMetaFilePict& metaFile, const TRect* rect);
  204.     void        PlayEnhMetaFileRecord(HANDLETABLE& handletable,
  205.                                       ENHMETARECORD& metaRecord, uint count);
  206. #endif
  207.  
  208.     // Output functions- Current position
  209.     //
  210.     bool        GetCurrentPosition(TPoint& point) const;
  211.     bool        MoveTo(int x, int y);
  212.     bool        MoveTo(const TPoint& point);
  213.     bool        MoveTo(const TPoint& point, TPoint& oldPoint);
  214.  
  215.     // Output functions- Icons & cursors
  216.     //
  217.     bool        DrawIcon(int x, int y, const TIcon& icon);
  218.     bool        DrawIcon(const TPoint& point, const TIcon& icon);
  219.     bool        DrawCursor(int x, int y, const TCursor& cursor);
  220.     bool        DrawCursor(const TPoint& point, const TCursor& cursor);
  221. #if defined(BI_PLAT_WIN32)
  222.     bool        DrawIcon(int x, int y, const TIcon& icon, int w, int h,
  223.                          int aniStep=0, HBRUSH bkBr=0, uint flags=DI_NORMAL);
  224.     bool        DrawIcon(const TPoint& point, const TIcon& icon,
  225.                          const TSize& size, int aniStep=0, HBRUSH bkBr=0,
  226.                          uint flags=DI_NORMAL);
  227.     bool        DrawCursor(int x, int y, const TCursor& cursor, int w, int h,
  228.                            int aniStep=0, HBRUSH bkBr=0, uint flags=DI_NORMAL);
  229.     bool        DrawCursor(const TPoint& point, const TCursor& cursor,
  230.                            const TSize& size, int aniStep=0, HBRUSH bkBr=0,
  231.                            uint flags=DI_NORMAL);
  232. #endif
  233.  
  234.     // Output functions- Rects
  235.     //
  236.     bool        FrameRect(int x1, int y1, int x2, int y2, const TBrush& brush);
  237.     bool        FrameRect(const TRect& rect, const TBrush& brush);
  238.     bool        FillRect(int x1, int y1, int x2, int y2, const TBrush& brush);
  239.     bool        FillRect(const TRect& rect, const TBrush& brush);
  240.     bool        InvertRect(int x1, int y1, int x2, int y2);
  241.     bool        InvertRect(const TRect& rect);
  242.     bool        DrawFocusRect(int x1, int y1, int x2, int y2);
  243.     bool        DrawFocusRect(const TRect& rect);
  244.  
  245.     // Filled rect using ExtTextOut, no dithered colors & uses or sets BkColor
  246.     //
  247.     bool        TextRect(int x1, int y1, int x2, int y2);
  248.     bool        TextRect(const TRect& rect);
  249.     bool        TextRect(int x1, int y1, int x2, int y2, const TColor& color);
  250.     bool        TextRect(const TRect& rect, const TColor& color);
  251.  
  252.     //
  253.     //
  254.     void        OWLFastWindowFrame(TBrush &brush, TRect &r, int xWidth, int yWidth);
  255.  
  256.     // Output functions- Regions
  257.     //
  258.     bool        FrameRgn(const TRegion& region, const TBrush& brush, const TPoint& p);
  259.     bool        FillRgn(const TRegion& region, const TBrush& brush);
  260.     bool        InvertRgn(const TRegion& region);
  261.     bool        PaintRgn(const TRegion& region);
  262.  
  263.     // Output functions- Shapes
  264.     //
  265. #if defined(BI_PLAT_WIN32)
  266.     bool        AngleArc(int x, int y, uint32 radius, float startAngle,
  267.                          float sweepAngle);
  268.     bool        AngleArc(const TPoint& center, uint32 radius, float startAngle,
  269.                          float sweepAngle);
  270. #endif
  271.     bool        Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
  272.                     int y4);
  273.     bool        Arc(const TRect& r, const TPoint& start, const TPoint& end);
  274.     bool        Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
  275.                       int y4);
  276.     bool        Chord(const TRect& R, const TPoint& Start, const TPoint& End);
  277.     bool        Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
  278.                     int y4);
  279.     bool        Pie(const TRect& rect, const TPoint& start, const TPoint& end);
  280.     bool        Ellipse(int x1, int y1, int x2, int y2);
  281.     bool        Ellipse(const TPoint& p1, const TPoint& p2);
  282.     bool        Ellipse(const TPoint& point, const TSize& size);
  283.     bool        Ellipse(const TRect& rect);
  284.     bool        LineTo(int x, int y);
  285.     bool        LineTo(const TPoint& point);
  286.     bool        Polyline(const TPoint* points, int count);
  287.     bool        Polygon(const TPoint* points, int count);
  288.     bool        PolyPolygon(const TPoint* points, const int* PolyCounts,
  289.                             int count);
  290. #if defined(BI_PLAT_WIN32)
  291.     bool        PolyPolyline(const TPoint* points, const int* PolyCounts,
  292.                              int count);
  293.     bool        PolyBezier(const TPoint* points, int count);
  294.     bool        PolyBezierTo(const TPoint* points, int count);
  295.     bool        PolyDraw(const TPoint* points, uint8* types, int count);
  296.     bool        PolylineTo(const TPoint* points, int count);
  297. #endif
  298.     bool        Rectangle(int x1, int y1, int x2, int y2);
  299.     bool        Rectangle(const TPoint& p1, const TPoint& p2);
  300.     bool        Rectangle(const TPoint& point, const TSize& s);
  301.     bool        Rectangle(const TRect& rect);
  302.     bool        RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);
  303.     bool        RoundRect(const TPoint& p1, const TPoint& p2, const TPoint& rad);
  304.     bool        RoundRect(const TPoint& p, const TSize& s, const TPoint& rad);
  305.     bool        RoundRect(const TRect& rect, const TPoint& rad);
  306.  
  307.     // Output functions- bitmaps & blitting
  308.     //
  309.     TColor      GetPixel(int x, int y) const;
  310.     TColor      GetPixel(const TPoint& point) const;
  311.     TColor      SetPixel(int x, int y, const TColor& color);
  312.     TColor      SetPixel(const TPoint& p, const TColor& color);
  313.     bool        BitBlt(int dstX, int dstY, int w, int h, const TDC& srcDC,
  314.                        int srcX, int srcY, uint32 rop=SRCCOPY);
  315.     bool        BitBlt(const TRect& dst, const TDC& srcDC,
  316.                        const TPoint& src, uint32 rop=SRCCOPY);
  317.     bool        PatBlt(int x, int y, int w, int h, uint32 rop=PATCOPY);
  318.     bool        PatBlt(const TRect& dst, uint32 rop=PATCOPY);
  319.     bool        ScrollDC(int x, int y, const TRect& scroll, const TRect& clip,
  320.                          TRegion& updateRgn, TRect& updateRect);
  321.     bool        ScrollDC(const TPoint& delta, const TRect& scroll,
  322.                          const TRect& clip, TRegion& updateRgn,
  323.                          TRect& updateRect);
  324.     bool        StretchBlt(int dstX, int dstY, int dstW, int dstH,
  325.                            const TDC& srcDC, int srcX, int srcY, int srcW,
  326.                            int srcH, uint32 rop=SRCCOPY);
  327.     bool        StretchBlt(const TRect& dst, const TDC& srcDC,
  328.                            const TRect& src, uint32 rop=SRCCOPY);
  329. #if defined(BI_PLAT_WIN32)
  330.     bool        MaskBlt(const TRect& dst, const TDC& srcDC,
  331.                         const TPoint& src, const TBitmap& maskBm,
  332.                         const TPoint& maskPos, uint32 rop=SRCCOPY);
  333.     bool        PlgBlt(const TPoint& dst, const TDC& srcDC,
  334.                        const TRect& src, const TBitmap& maskBm,
  335.                        const TPoint& maskPos);
  336. #endif
  337.     bool        GetDIBits(const TBitmap& bitmap, uint startScan, uint numScans,
  338.                           void HUGE* bits, const BITMAPINFO far& info,
  339.                           uint16 usage);
  340.     bool        GetDIBits(const TBitmap& bitmap, TDib& dib);
  341.     bool        SetDIBits(TBitmap& bitmap, uint startScan, uint numScans,
  342.                           const void HUGE* bits, const BITMAPINFO far& Info,
  343.                           uint16 usage);
  344.     bool        SetDIBits(TBitmap& bitmap, const TDib& dib);
  345.     bool        SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  346.                                   uint startScan, uint numScans,
  347.                                   const void HUGE* bits,
  348.                                   const BITMAPINFO far& bitsInfo, uint16 usage);
  349.     bool        SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  350.                                   const TDib& dib);
  351.     bool        StretchDIBits(const TRect& dst, const TRect& src,
  352.                               const void HUGE* bits,
  353.                               const BITMAPINFO far& bitsInfo,
  354.                               uint16 usage, uint32 rop=SRCCOPY);
  355.     bool        StretchDIBits(const TRect& dst, const TRect& src,
  356.                               const TDib& dib, uint32 rop=SRCCOPY);
  357.  
  358. #if defined(BI_PLAT_WIN32)
  359.     HBITMAP     CreateDIBSection(const BITMAPINFO& info, uint usage, void** bits, HANDLE section=0, uint32 offset=0);
  360. #endif
  361.  
  362.     bool        FloodFill(const TPoint& point, const TColor& color);
  363.     bool        ExtFloodFill(const TPoint& point, const TColor& color, uint16 fillType);
  364.  
  365.     // Output functions- text
  366.     //
  367.     virtual bool TextOut(int x, int y, const char far* str, int count=-1);
  368.     bool         TextOut(const TPoint& p, const char far* str, int count=-1);
  369.     virtual bool ExtTextOut(int x, int y, uint16 options, const TRect* r,
  370.                             const char far* str, int count=-1,
  371.                             const int far* dx = 0);
  372.     bool         ExtTextOut(const TPoint& p, uint16 options, const TRect* r,
  373.                             const char far* str, int count=-1,
  374.                             const int far* dx = 0);
  375.     virtual bool TabbedTextOut(const TPoint& p, const char far* str, int count,
  376.                                int numPositions, const int far* positions,
  377.                                int tabOrigin, TSize& size);
  378.     bool         TabbedTextOut(const TPoint& p, const char far* str, int count,
  379.                                int numPositions, const int far* positions,
  380.                                int tabOrigin);
  381.     virtual int  DrawText(const char far* str, int count, const TRect& r,
  382.                           uint16 format=0);
  383.     virtual bool GrayString(const TBrush& brush, GRAYSTRINGPROC outputFunc,
  384.                             const char far* str, int count, const TRect& r);
  385.  
  386.     // Text functions
  387.     //
  388.     bool        GetTextExtent(const char far* str, int stringLen, TSize& size);
  389.     TSize       GetTextExtent(const char far* str, int stringLen);
  390.     bool        GetTabbedTextExtent(const char far* str, int stringLen,
  391.                                     int numPositions, const int far* positions,
  392.                                     TSize& size) const;
  393.     TSize       GetTabbedTextExtent(const char far* str, int stringLen,
  394.                               int numPositions, const int far* positions) const;
  395.     uint        GetTextAlign() const;
  396.     uint        SetTextAlign(uint flags);
  397.     int         GetTextCharacterExtra() const;
  398.     int         SetTextCharacterExtra(int extra);
  399.     bool        SetTextJustification(int breakExtra, int breakCount);
  400.     int         GetTextFace(int count, char far* facename) const;
  401.     bool        GetTextMetrics(TEXTMETRIC far& metrics) const;
  402.     uint32      GetGlyphOutline(uint chr, uint format, GLYPHMETRICS far& gm,
  403.                                 uint32 buffSize, void far* buffer,
  404.                                 const MAT2 far& mat2);
  405.     int         GetKerningPairs(int pairs, KERNINGPAIR far* krnPair);
  406.     uint        GetOutlineTextMetrics(uint data, OUTLINETEXTMETRIC far& otm);
  407.  
  408.     // Font functions
  409.     //
  410.     bool        GetCharWidth(uint firstChar, uint lastChar, int* buffer);
  411.     uint32      SetMapperFlags(uint32 flag);
  412.     bool        GetAspectRatioFilter(TSize& size) const;
  413.     int         EnumFonts(const char far* faceName, OLDFONTENUMPROC callback,
  414.                           void far* data) const;
  415.     int         EnumFontFamilies(const char far* family,
  416.                                  FONTENUMPROC proc, void far* data) const;
  417.     uint32      GetFontData(uint32 table, uint32 offset, void* buffer, long data);
  418.     bool        GetCharABCWidths(uint firstChar, uint lastChar, ABC* abc);
  419.  
  420.     // Path functions
  421.     //
  422. #if defined(BI_PLAT_WIN32)
  423.     bool        BeginPath();
  424.     bool        CloseFigure();
  425.     bool        EndPath();
  426.     bool        FlattenPath();
  427.     bool        WidenPath();
  428.     bool        FillPath();
  429.     bool        StrokePath();
  430.     bool        StrokeAndFillPath();
  431.     bool        SelectClipPath(int mode);
  432.     HRGN        PathToRegion();
  433. #endif
  434.  
  435.     // Override to implement a twin DC object, like TPrintPreviewDC
  436.     //
  437.     virtual HDC GetAttributeHDC() const;
  438.     HDC         GetHDC() const;
  439.  
  440.   protected:
  441.     TDC();          // For use by derived classes only
  442.     TDC(HDC handle, TAutoDelete autoDelete); //use an existing DC
  443.     void        Init();
  444.  
  445.   protected_data:
  446.     TGdiBase::CheckValid;       // make this function available to derivatives
  447.     TGdiBase::Handle;           // The handle of this DC
  448.     TGdiBase::ShouldDelete;     // Should object delete the Handle in dtor?
  449.  
  450.     HBRUSH      OrgBrush;       // Original objects when DC was created
  451.     HPEN        OrgPen;
  452.     HFONT       OrgFont;
  453.     HPALETTE    OrgPalette;
  454. #if defined(BI_PLAT_WIN32)
  455.     HBRUSH      OrgTextBrush;
  456. #endif
  457.  
  458.   private:
  459.     // Hidden to prevent accidental copying or assignment
  460.     //
  461.     TDC(const TDC&);
  462.     TDC& operator =(const TDC&);
  463. };
  464.  
  465. //
  466. // class TWindowDC
  467. // ~~~~~ ~~~~~~~~~
  468. // A DC class that provides access to the entire area owned by a window. Is
  469. // the base for any DC class that Releases its handle when done.
  470. //
  471. class _OWLCLASS TWindowDC : public TDC {
  472.   public:
  473.     TWindowDC(HWND wnd);
  474.    ~TWindowDC();
  475.  
  476.   protected:
  477.     HWND        Wnd;
  478.     TWindowDC();  // for derived classes
  479.  
  480.   private:
  481.     TWindowDC(const TWindowDC&);
  482.     TWindowDC& operator =(const TWindowDC&);
  483. };
  484.  
  485. //
  486. // class TScreenDC
  487. // ~~~~~ ~~~~~~~~~
  488. // A DC class that provides direct access to the screen bitmap.  Gets a DC for
  489. // Window handle 0, which is for the whole screen w/ no clipping, etc. will
  490. // paint on top of everything.
  491. //
  492. class _OWLCLASS TScreenDC : public TWindowDC {
  493.   public:
  494.     TScreenDC();
  495.  
  496.   private:
  497.     TScreenDC(const TScreenDC&);
  498.     TScreenDC& operator =(const TScreenDC&);
  499. };
  500.  
  501. //
  502. // class TDesktopDC
  503. // ~~~~~ ~~~~~~~~~~
  504. // A DC class that provides access to the desktop window's client area which
  505. // is the window behind all other windows.
  506. //
  507. class _OWLCLASS TDesktopDC : public TWindowDC {
  508.   public:
  509.     TDesktopDC();
  510.  
  511.   private:
  512.     TDesktopDC(const TDesktopDC&);
  513.     TDesktopDC& operator =(const TDesktopDC&);
  514. };
  515.  
  516. //
  517. // class TClientDC
  518. // ~~~~~ ~~~~~~~~~
  519. // A DC class that provides access to the client area owned by a window
  520. //
  521. class _OWLCLASS TClientDC : public TWindowDC {
  522.   public:
  523.     TClientDC(HWND wnd);
  524.  
  525.   private:
  526.     TClientDC(const TClientDC&);
  527.     TClientDC& operator =(const TClientDC&);
  528. };
  529.  
  530. //
  531. // class TPaintDC
  532. // ~~~~~ ~~~~~~~~
  533. // A DC class that wraps begin and end paint calls for use in an WM_PAINT
  534. // response function.
  535. //
  536. class _OWLCLASS TPaintDC : public TDC {
  537.   public:
  538.     TPaintDC(HWND wnd);
  539.    ~TPaintDC();
  540.  
  541.     PAINTSTRUCT Ps;
  542.  
  543.   protected:
  544.     HWND        Wnd;
  545.  
  546.   private:
  547.     TPaintDC(const TPaintDC&);
  548.     TPaintDC& operator =(const TPaintDC&);
  549. };
  550.  
  551. //
  552. // class TMetaFileDC
  553. // ~~~~~ ~~~~~~~~~~~
  554. // A DC class that provides access to a DC with a metafile selected into it
  555. // for drawing on (into).
  556. //
  557. class _OWLCLASS TMetaFileDC : public TDC {
  558.   public:
  559.     TMetaFileDC(const char far* filename = 0);
  560. #if defined(BI_PLAT_WIN32)
  561.     TMetaFileDC(const TDC& dc, const char far* filename = 0, TRect* rect = 0,
  562.                 const char far* description = 0);
  563. #endif
  564.    ~TMetaFileDC();
  565.  
  566.     HMETAFILE Close();
  567.  
  568. #if defined(BI_PLAT_WIN32)
  569.     HENHMETAFILE CloseEnh();
  570.     bool Comment(uint bytes, const void* data);
  571. #endif
  572.  
  573.     bool IsEnhanced() const;
  574.  
  575.   private:
  576.     bool Enhanced;
  577.  
  578.     TMetaFileDC(const TMetaFileDC&);
  579.     TMetaFileDC& operator =(const TMetaFileDC&);
  580. };
  581.  
  582. //
  583. // class TCreatedDC
  584. // ~~~~~ ~~~~~~~~~~
  585. // Base class for DC classes that create DC handles vs. getting them from the
  586. // cache
  587. //
  588. class _OWLCLASS TCreatedDC : public TDC {
  589.   public:
  590.     TCreatedDC(const char far* driver, const char far* device,
  591.                const char far* output, const DEVMODE far* initData=0);
  592.  
  593.     TCreatedDC(HDC handle, TAutoDelete autoDelete);  // use an existing DC
  594.    ~TCreatedDC();
  595.  
  596.   protected:
  597.     TCreatedDC();
  598.  
  599.   private:
  600.     TCreatedDC(const TCreatedDC&);
  601.     TCreatedDC& operator =(const TCreatedDC&);
  602. };
  603.  
  604. //
  605. // class TIC
  606. // ~~~~~ ~~~
  607. // An information only device context
  608. //
  609. class _OWLCLASS TIC : public TCreatedDC {
  610.   public:
  611.     TIC(const char far* driver, const char far* device,
  612.         const char far* output, const DEVMODE far* initData=0);
  613.    ~TIC();
  614.  
  615.   private:
  616.     TIC(const TIC&);
  617.     TIC& operator =(const TIC&);
  618. };
  619.  
  620. //
  621. // class TMemoryDC
  622. // ~~~~~ ~~~~~~~~~
  623. // A DC class that provides access to a memory DC
  624. //
  625. class _OWLCLASS TMemoryDC : public TCreatedDC {
  626.   public:
  627.     TMemoryDC();
  628.     TMemoryDC(const TDC& DC); // Make it compatible with an existing DC
  629.     TMemoryDC(HDC handle, TAutoDelete autoDelete);  // wrap an existing DC
  630.     TMemoryDC(TBitmap& bitmap);                  // Select a bitmap right away
  631.    ~TMemoryDC();
  632.  
  633.     // Select GDI objects into this DC and restore them to original
  634.     //
  635.     void        SelectObject(const TBrush& brush);
  636.     void        SelectObject(const TPen& pen);
  637.     void        SelectObject(const TFont& font);
  638.     void        SelectObject(const TPalette& palette, bool forceBackground=false);
  639.     void        SelectObject(const TBitmap& bitmap);
  640.  
  641.     void        RestoreBitmap();
  642.     void        RestoreObjects();
  643.  
  644.   protected:
  645.     TMemoryDC(const char far* driver, const char far* device,
  646.               const char far* output, const DEVMODE far* initData=0);
  647.  
  648.     HBITMAP     OrgBitmap;
  649.  
  650.   private:
  651.     void Init();
  652.  
  653.     TMemoryDC(const TMemoryDC&);
  654.     TMemoryDC& operator =(const TMemoryDC&);
  655. };
  656.  
  657. //
  658. // class TDibDC
  659. // ~~~~~ ~~~~~~
  660. // A DC class that provides access to DIBs using DIBSection, WinG, or the
  661. // DIB.DRV driver
  662. //
  663. class _OWLCLASS TDibDC : public TMemoryDC {
  664.   public:
  665.     TDibDC();
  666.     TDibDC(const TBitmap& bitmap);
  667.  
  668.     uint        GetDIBColorTable(uint start, uint entries, RGBQUAD far* colors);
  669.     uint        SetDIBColorTable(uint start, uint entries, const RGBQUAD far* colors);
  670.  
  671.     // Screen Update BitBlt's.  DC for display must be the destination.
  672.     //
  673.     bool BitBltToScreen(TDC& dstDC, const TRect& dst, const TPoint& src) const;
  674.     bool BitBltToScreen(TDC& dstDC, int dstX, int dstY, int dstW, int dstH,
  675.                         int srcX=0, int srcY=0) const;
  676.     bool StretchBltToScreen(TDC& dstDC, const TRect& dst, const TRect& src) const;
  677.     bool StretchBltToScreen(TDC& dstDC, int dstX, int dstY, int dstW, int dstH,
  678.                             int srcX, int srcY, int srcW, int srcH) const;
  679.  
  680.   private:
  681.     // prevent accidental copying of object
  682.     //
  683.     TDibDC(const TDibDC&);
  684.     TDibDC& operator =(const TDibDC&);
  685. };
  686.  
  687. //
  688. // struct TBandInfo
  689. // ~~~~~~ ~~~~~~~~~
  690. // Equivalent to BANDINFOSTRUCT
  691. //
  692. struct TBandInfo {
  693.   bool  HasGraphics;
  694.   bool  HasText;
  695.   TRect GraphicsRect;
  696. };
  697.  
  698. //
  699. // class TPrintDC
  700. // ~~~~~ ~~~~~~~~
  701. // A DC class that provides access to a printer
  702. //
  703. class _OWLCLASS TPrintDC : public TCreatedDC {
  704.   public:
  705.     TPrintDC(HDC handle, TAutoDelete autoDelete = NoAutoDelete);
  706.     TPrintDC(const char far* driver, const char far* device,
  707.              const char far* output, const DEVMODE far* initData);
  708.  
  709.     int         Escape(int escape, int count=0, const void* inData=0,
  710.                        void* outData=0);
  711.     int         SetAbortProc(ABORTPROC proc);
  712.     int         StartDoc(const char far* docName, const char far* output);
  713.     int         StartPage();
  714.     int         BandInfo(TBandInfo& bandInfo);
  715.     int         NextBand(TRect& rect);
  716.     int         EndPage();
  717.     int         EndDoc();
  718.     int         AbortDoc();
  719.  
  720. #if defined(BI_PLAT_WIN16)
  721.     bool        QueryAbort(int rsvd=0);
  722. #endif
  723.  
  724.     uint        QueryEscSupport(int escapeNum);
  725.     int         SetCopyCount(int reqestCount, int& actualCount);
  726.  
  727.     static uint32 DeviceCapabilities(const char far* driver,
  728.                                     const char far* device,
  729.                                     const char far* port,
  730.                                     int capability, char far* output=0,
  731.                                     LPDEVMODE devmode=0);
  732.   protected:
  733.     DOCINFO&    GetDocInfo();
  734.     void        SetDocInfo(const DOCINFO& docinfo);
  735.  
  736.   protected_data:
  737.     DOCINFO     DocInfo;
  738.  
  739.   private:
  740.     TPrintDC(const TPrintDC&);
  741.     TPrintDC& operator =(const TPrintDC&);
  742. };
  743.  
  744. // Generic definitions/compiler options (eg. alignment) following the 
  745. // definition of classes
  746. #include <services/posclass.h>
  747.  
  748. #if defined(BI_NAMESPACE)
  749. } // namespace OWL
  750. #endif
  751.  
  752. //----------------------------------------------------------------------------
  753. // Inlines for DC classes
  754. //
  755.  
  756. //
  757. // Get the GDI object headers so that we have access to conversion operators,
  758. // etc.
  759. //
  760. #if !defined(OWL_GDIOBJEC_H)
  761. # include <owl/gdiobjec.h>
  762. #endif
  763. #if !defined(OWL_METAFILE_H)
  764. # include <owl/metafile.h>
  765. #endif
  766.  
  767. //
  768. // Return the handle of the device context.
  769. //
  770. inline TDC::operator HDC() const
  771. {
  772.   return HDC(Handle);
  773. }
  774.  
  775. //
  776. // Return the handle of the device context.
  777. //
  778. inline HDC TDC::GetHDC()const
  779. {
  780.   return HDC(Handle);
  781. }
  782.  
  783. //
  784. // Attempt to validate the device context handle and return true if the
  785. // validation succeeded, or false otherwise.
  786. //
  787. inline bool TDC::IsDC() const
  788. {
  789. #if   defined(BI_PLAT_WIN32)
  790.   //
  791.   return ::GetObjectType(GetHDC()) != 0;
  792. #elif defined(BI_PLAT_WIN16)
  793.   return ::IsGDIObject(GetHDC()) != 0;
  794. #endif
  795. }
  796.  
  797. //
  798. inline bool TDC::GetDCOrg(TPoint& point) const
  799. {
  800. #if defined(BI_PLAT_WIN32)
  801.   return ::GetDCOrgEx(GetAttributeHDC(), &point);
  802. #else
  803.   point = ::GetDCOrg(GetAttributeHDC());
  804.   return true;
  805. #endif
  806. }
  807.  
  808. //
  809. inline bool TDC::GetBrushOrg(TPoint& point) const
  810. {
  811.   return ::GetBrushOrgEx(GetHDC(), &point);
  812. }
  813.  
  814. //
  815. inline bool TDC::SetBrushOrg(const TPoint& org, TPoint far* oldOrg)
  816. {
  817. #if defined(BI_PLAT_WIN32)
  818.   return ::SetBrushOrgEx(GetHDC(), org.x, org.y, oldOrg);
  819. #else
  820.   if (oldOrg)
  821.     *oldOrg = ::SetBrushOrg(GetHDC(), org.x, org.y);
  822.   else
  823.     ::SetBrushOrg(GetHDC(), org.x, org.y);
  824.   return true;
  825. #endif
  826. }
  827.  
  828. //
  829. inline int TDC::EnumObjects(uint objectType, GOBJENUMPROC proc, void far* data) const
  830. {
  831.   return ::EnumObjects(GetHDC(), objectType, proc, (LPARAM)data);
  832. }
  833.  
  834. //
  835. inline TColor TDC::GetNearestColor(const TColor& color) const
  836. {
  837.   return ::GetNearestColor(GetAttributeHDC(), color);
  838. }
  839.  
  840. //
  841. inline int TDC::RealizePalette()
  842. {
  843.   return ::RealizePalette(GetHDC());
  844. }
  845.  
  846. //
  847. inline void TDC::UpdateColors()
  848. {
  849.   ::UpdateColors(GetHDC());
  850. }
  851.  
  852. //
  853. inline uint TDC::GetSystemPaletteEntries(int start, int num, PALETTEENTRY far* entries) const
  854. {
  855.   return ::GetSystemPaletteEntries(GetHDC(), start, num, entries);
  856. }
  857.  
  858. //
  859. inline uint TDC::GetSystemPaletteUse() const
  860. {
  861.   return ::GetSystemPaletteUse(GetHDC());
  862. }
  863.  
  864. //
  865. inline int TDC::SetSystemPaletteUse(int usage)
  866. {
  867.   return ::SetSystemPaletteUse(GetHDC(), usage);
  868. }
  869.  
  870. //
  871. inline TColor TDC::GetBkColor() const
  872. {
  873.   return ::GetBkColor(GetAttributeHDC());
  874. }
  875.  
  876. //
  877. inline int TDC::GetBkMode() const
  878. {
  879.   return ::GetBkMode(GetAttributeHDC());
  880. }
  881.  
  882. //
  883. inline int TDC::SetBkMode(int mode)
  884. {
  885.   if (GetHDC() != GetAttributeHDC())
  886.     ::SetBkMode(GetHDC(), mode);
  887.   return ::SetBkMode(GetAttributeHDC(), mode);
  888. }
  889.  
  890. //
  891. inline int TDC::GetPolyFillMode() const
  892. {
  893.   return ::GetPolyFillMode(GetAttributeHDC());
  894. }
  895.  
  896. //
  897. inline int TDC::SetPolyFillMode(int mode)
  898. {
  899.   if (GetHDC() != GetAttributeHDC())
  900.     ::SetPolyFillMode(GetHDC(), mode);
  901.   return ::SetPolyFillMode(GetAttributeHDC(), mode);
  902. }
  903.  
  904. //
  905. inline int TDC::GetROP2() const
  906. {
  907.   return ::GetROP2(GetAttributeHDC());
  908. }
  909.  
  910. //
  911. inline int TDC::SetROP2(int mode)
  912. {
  913.   if (GetHDC() != GetAttributeHDC())
  914.     ::SetROP2(GetHDC(), mode);
  915.   return ::SetROP2(GetAttributeHDC(), mode);
  916. }
  917.  
  918. //
  919. inline int TDC::GetStretchBltMode() const
  920. {
  921.   return ::GetStretchBltMode(GetAttributeHDC());
  922. }
  923.  
  924. //
  925. inline int TDC::SetStretchBltMode(int mode)
  926. {
  927.   if (GetHDC() != GetAttributeHDC())
  928.     ::SetStretchBltMode(GetHDC(), mode);
  929.   return ::SetStretchBltMode(GetAttributeHDC(), mode);
  930. }
  931.  
  932. //
  933. inline TColor TDC::GetTextColor() const
  934. {
  935.   return ::GetTextColor(GetAttributeHDC());
  936. }
  937.  
  938. //
  939. inline int TDC::GetMapMode() const
  940. {
  941.   return ::GetMapMode(GetAttributeHDC());
  942. }
  943.  
  944. #if defined(BI_PLAT_WIN32)
  945.  
  946. //
  947. inline bool TDC::SetMiterLimit(float newLimit, float* oldLimit)
  948. {
  949.   if (GetHDC() != GetAttributeHDC())
  950.     ::SetMiterLimit(GetHDC(), newLimit, oldLimit);
  951.   return ::SetMiterLimit(GetAttributeHDC(), newLimit, oldLimit);
  952. }
  953.  
  954. //
  955. inline bool TDC::SetWorldTransform(XFORM far& xform)
  956. {
  957.   if (GetHDC() != GetAttributeHDC())
  958.     ::SetWorldTransform(GetHDC(), &xform);
  959.   return ::SetWorldTransform(GetAttributeHDC(), &xform);
  960. }
  961.  
  962. //
  963. inline bool TDC::ModifyWorldTransform(XFORM far& xform, uint32 mode)
  964. {
  965.   if (GetHDC() != GetAttributeHDC())
  966.     ::ModifyWorldTransform(GetHDC(), &xform, mode);
  967.   return ::ModifyWorldTransform(GetAttributeHDC(), &xform, mode);
  968. }
  969.  
  970. #endif  // defined(BI_PLAT_WIN32)
  971.  
  972. //
  973. inline bool TDC::GetViewportOrg(TPoint& point) const
  974. {
  975.   return ::GetViewportOrgEx(GetAttributeHDC(), &point);
  976. }
  977.  
  978. //
  979. inline TPoint TDC::GetViewportOrg() const
  980. {
  981. #if defined(BI_PLAT_WIN32)
  982.   TPoint point;
  983.   ::GetViewportOrgEx(GetAttributeHDC(), &point);
  984.   return point;
  985. #else
  986.   return ::GetViewportOrg(GetAttributeHDC());
  987. #endif
  988. }
  989.  
  990. //
  991. inline bool TDC::GetViewportExt(TSize& extent) const
  992. {
  993.   return ::GetViewportExtEx(GetAttributeHDC(), &extent);
  994. }
  995.  
  996. //
  997. inline TSize TDC::GetViewportExt() const
  998. {
  999. #if defined(BI_PLAT_WIN32)
  1000.   TSize extent;
  1001.   ::GetViewportExtEx(GetAttributeHDC(), &extent);
  1002.   return extent;
  1003. #else
  1004.   return ::GetViewportExt(GetAttributeHDC());
  1005. #endif
  1006. }
  1007.  
  1008. //
  1009. inline bool TDC::GetWindowOrg(TPoint& point) const
  1010. {
  1011.   return ::GetWindowOrgEx(GetAttributeHDC(), &point);
  1012. }
  1013.  
  1014. //
  1015. inline TPoint TDC::GetWindowOrg() const
  1016. {
  1017. #if defined(BI_PLAT_WIN32)
  1018.   TPoint point;
  1019.   ::GetWindowOrgEx(GetAttributeHDC(), &point);
  1020.   return point;
  1021. #else
  1022.   return ::GetWindowOrg(GetAttributeHDC());
  1023. #endif
  1024. }
  1025.  
  1026. //
  1027. inline bool TDC::GetWindowExt(TSize& extent) const
  1028. {
  1029.   return ::GetWindowExtEx(GetAttributeHDC(), &extent);
  1030. }
  1031.  
  1032. //
  1033. inline TSize TDC::GetWindowExt() const
  1034. {
  1035. #if defined(BI_PLAT_WIN32)
  1036.   TSize extent;
  1037.   ::GetWindowExtEx(GetAttributeHDC(), &extent);
  1038.   return extent;
  1039. #else
  1040.   return ::GetWindowExt(GetAttributeHDC());
  1041. #endif
  1042. }
  1043.  
  1044. //
  1045. inline bool TDC::DPtoLP(TPoint* points, int count) const
  1046. {
  1047.   return ::DPtoLP(GetAttributeHDC(), points, count);
  1048. }
  1049.  
  1050. //
  1051. inline bool TDC::DPtoLP(TRect& rect) const
  1052. {
  1053.   return ::DPtoLP(GetAttributeHDC(), (LPPOINT)&rect, 2);
  1054. }
  1055.  
  1056. //
  1057. inline bool TDC::LPtoDP(TPoint* points, int count) const
  1058. {
  1059.   return ::LPtoDP(GetAttributeHDC(), points, count);
  1060. }
  1061.  
  1062. //
  1063. inline bool TDC::LPtoDP(TRect& rect) const
  1064. {
  1065.   return ::LPtoDP(GetAttributeHDC(), (LPPOINT)&rect, 2);
  1066. }
  1067.  
  1068. //
  1069. inline int TDC::GetClipBox(TRect& rect) const
  1070. {
  1071.   return ::GetClipBox(GetHDC(), &rect);
  1072. }
  1073.  
  1074. //
  1075. inline TRect TDC::GetClipBox() const
  1076. {
  1077.   TRect rect;
  1078.   ::GetClipBox(GetHDC(), &rect);
  1079.   return rect;
  1080. }
  1081.  
  1082. //
  1083. inline int TDC::ExcludeClipRect(const TRect& rect)
  1084. {
  1085.   return ::ExcludeClipRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  1086. }
  1087.  
  1088. //
  1089. inline int TDC::ExcludeUpdateRgn(HWND Wnd)
  1090. {
  1091.   return ::ExcludeUpdateRgn(GetHDC(), Wnd);
  1092. }
  1093.  
  1094. //
  1095. inline int TDC::IntersectClipRect(const TRect& rect)
  1096. {
  1097.   return ::IntersectClipRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  1098. }
  1099.  
  1100. //
  1101. inline int TDC::OffsetClipRgn(const TPoint& delta)
  1102. {
  1103.   return ::OffsetClipRgn(GetHDC(), delta.x, delta.y);
  1104. }
  1105.  
  1106. //
  1107. inline int TDC::SelectClipRgn(const TRegion& region)
  1108. {
  1109.   return ::SelectClipRgn(GetHDC(), region);
  1110. }
  1111.  
  1112. //
  1113. inline bool TDC::PtVisible(const TPoint& point) const
  1114. {
  1115.   return ::PtVisible(GetHDC(), point.x, point.y);
  1116. }
  1117.  
  1118. //
  1119. inline bool TDC::RectVisible(const TRect& rect) const
  1120. {
  1121.   return ::RectVisible(GetHDC(), &rect);
  1122. }
  1123.  
  1124. //
  1125. inline bool TDC::GetBoundsRect(TRect& bounds, uint16 flags) const
  1126. {
  1127.   return ::GetBoundsRect(GetHDC(), &bounds, flags);
  1128. }
  1129.  
  1130. //
  1131. inline uint TDC::SetBoundsRect(TRect& bounds, uint flags)
  1132. {
  1133.   return ::SetBoundsRect(GetHDC(), &bounds, flags);
  1134. }
  1135.  
  1136. #if defined(BI_PLAT_WIN32)
  1137. //
  1138. inline bool TDC::GetClipRgn(TRegion& region) const
  1139. {
  1140.   return ::GetClipRgn(GetHDC(), region);
  1141. }
  1142. #endif
  1143.  
  1144. //
  1145. inline int TDC::EnumMetaFile(const TMetaFilePict& metafile, MFENUMPROC callback,
  1146.                              void far* data) const
  1147. {
  1148.   return ::EnumMetaFile(GetHDC(), metafile, callback, (long)data);
  1149. }
  1150.  
  1151. //
  1152. inline bool TDC::PlayMetaFile(const TMetaFilePict& metafile)
  1153. {
  1154.   return ::PlayMetaFile(GetHDC(), metafile);
  1155. }
  1156.  
  1157. //
  1158. inline void TDC::PlayMetaFileRecord(HANDLETABLE far& handletable,
  1159.                                     METARECORD far& metaRecord, int count)
  1160. {
  1161.   ::PlayMetaFileRecord(GetHDC(), &handletable, &metaRecord, count);
  1162. }
  1163.  
  1164. #if defined(BI_PLAT_WIN32)
  1165. //
  1166. // Enumerate through the enhanced metafile records.
  1167. //
  1168. inline int TDC::EnumEnhMetaFile(const TEnhMetaFilePict& metafile, ENHMFENUMPROC callback,
  1169.                                 void far* data, const TRect* rect) const
  1170. {
  1171.   return ::EnumEnhMetaFile(GetHDC(), metafile, callback, data, rect);
  1172. }
  1173.  
  1174. //
  1175. // Play the enhanced metafile onto this device context.
  1176. //
  1177. inline bool TDC::PlayEnhMetaFile(const TEnhMetaFilePict& metafile, const TRect* rect)
  1178. {
  1179.   return ::PlayEnhMetaFile(GetHDC(), metafile, rect);
  1180. }
  1181.  
  1182. //
  1183. // Play one record from the enhanced metafile onto this DC.
  1184. //
  1185. inline void TDC::PlayEnhMetaFileRecord(HANDLETABLE far& handletable,
  1186.                                        ENHMETARECORD far& metaRecord, uint count)
  1187. {
  1188.   ::PlayEnhMetaFileRecord(GetHDC(), &handletable, &metaRecord, count);
  1189. }
  1190. #endif
  1191.  
  1192. //
  1193. inline bool TDC::GetCurrentPosition(TPoint& point) const
  1194. {
  1195.   return ::GetCurrentPositionEx(GetHDC(), &point);
  1196. }
  1197.  
  1198. //
  1199. inline bool TDC::MoveTo(int x, int y)
  1200. {
  1201.   return ::MoveToEx(GetHDC(), x, y, 0);
  1202. }
  1203.  
  1204. //
  1205. inline bool TDC::MoveTo(const TPoint& point)
  1206. {
  1207.   return ::MoveToEx(GetHDC(), point.x, point.y, 0);
  1208. }
  1209.  
  1210. //
  1211. inline bool TDC::MoveTo(const TPoint& point, TPoint& OldPoint)
  1212. {
  1213.   return ::MoveToEx(GetHDC(), point.x, point.y, &OldPoint);
  1214. }
  1215.  
  1216. //
  1217. inline bool TDC::DrawIcon(int x, int y, const TIcon& icon)
  1218. {
  1219.   return ::DrawIcon(GetHDC(), x, y, icon);
  1220. }
  1221.  
  1222. //
  1223. inline bool TDC::DrawIcon(const TPoint& point, const TIcon& icon)
  1224. {
  1225.   return ::DrawIcon(GetHDC(), point.x, point.y, icon);
  1226. }
  1227.  
  1228. //
  1229. inline bool TDC::DrawCursor(int x, int y, const TCursor& cursor)
  1230. {
  1231.   return ::DrawIcon(GetHDC(), x, y, HICON(HCURSOR(cursor)));
  1232. }
  1233.  
  1234. //
  1235. inline bool TDC::DrawCursor(const TPoint& point, const TCursor& cursor)
  1236. {
  1237.   return ::DrawIcon(GetHDC(), point.x, point.y, HICON(HCURSOR(cursor)));
  1238. }
  1239.  
  1240. #if defined(BI_PLAT_WIN32)
  1241. //
  1242. inline bool TDC::DrawIcon(int x, int y, const TIcon& icon, int w, int h,
  1243.                           int aniStep, HBRUSH bkBr, uint flags)
  1244. {
  1245.   return ::DrawIconEx(GetHDC(), x, y, icon, w, h, aniStep, bkBr, flags);
  1246. }
  1247.  
  1248. inline bool TDC::DrawIcon(const TPoint& point, const TIcon& icon,
  1249.                           const TSize& size, int aniStep, HBRUSH bkBr, uint flags)
  1250. {
  1251.   return ::DrawIconEx(GetHDC(), point.x, point.y, icon, size.cx, size.cy,
  1252.                       aniStep, bkBr, flags);
  1253. }
  1254.  
  1255. inline bool TDC::DrawCursor(int x, int y, const TCursor& cursor, int w, int h,
  1256.                             int aniStep, HBRUSH bkBr, uint flags)
  1257. {
  1258.   return ::DrawIconEx(GetHDC(), x, y, HICON(HCURSOR(cursor)), w, h, aniStep,
  1259.                       bkBr, flags);
  1260. }
  1261.  
  1262. inline bool TDC::DrawCursor(const TPoint& point, const TCursor& cursor,
  1263.                             const TSize& size, int aniStep, HBRUSH bkBr, uint flags)
  1264. {
  1265.   return ::DrawIconEx(GetHDC(), point.x, point.y, HICON(HCURSOR(cursor)),
  1266.                       size.cx, size.cy, aniStep, bkBr, flags);
  1267. }
  1268. #endif
  1269.  
  1270. //
  1271. inline bool TDC::FrameRect(int x1, int y1, int x2, int y2, const TBrush& brush)
  1272. {
  1273.   return ::FrameRect(GetHDC(), &TRect(x1, y1, x2, y2), brush);
  1274. }
  1275.  
  1276. //
  1277. inline bool TDC::FrameRect(const TRect& rect, const TBrush& brush)
  1278. {
  1279.   return ::FrameRect(GetHDC(), &rect, brush);
  1280. }
  1281.  
  1282. //
  1283. inline bool TDC::FillRect(int x1, int y1, int x2, int y2, const TBrush& brush)
  1284. {
  1285.   return ::FillRect(GetHDC(), &TRect(x1, y1, x2, y2), brush);
  1286. }
  1287.  
  1288. //
  1289. inline bool TDC::FillRect(const TRect& rect, const TBrush& brush)
  1290. {
  1291.   return ::FillRect(GetHDC(), &rect, brush);
  1292. }
  1293.  
  1294. //
  1295. // Rect must be normalized for inverRect
  1296. //
  1297. //
  1298. inline bool TDC::InvertRect(int x1, int y1, int x2, int y2)
  1299. {
  1300.   ::InvertRect(GetHDC(), &TRect(x1, y1, x2, y2));
  1301.   return true;
  1302. }
  1303.  
  1304. //
  1305. inline bool TDC::InvertRect(const TRect& rect)
  1306. {
  1307.   ::InvertRect(GetHDC(), &rect);
  1308.   return true;
  1309. }
  1310.  
  1311. //
  1312. inline bool TDC::DrawFocusRect(int x1, int y1, int x2, int y2)
  1313. {
  1314.   ::DrawFocusRect(GetHDC(), &TRect(x1, y1, x2, y2));
  1315.   return true;
  1316. }
  1317.  
  1318. //
  1319. inline bool TDC::DrawFocusRect(const TRect& rect)
  1320. {
  1321.   ::DrawFocusRect(GetHDC(), &rect);
  1322.   return true;
  1323. }
  1324.  
  1325. //
  1326. inline bool TDC::TextRect(int x1, int y1, int x2, int y2)
  1327. {
  1328.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &TRect(x1, y1, x2, y2), 0, 0, 0);
  1329. }
  1330.  
  1331. //
  1332. inline bool TDC::TextRect(const TRect& rect)
  1333. {
  1334.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
  1335. }
  1336.  
  1337. //
  1338. inline bool TDC::TextRect(int x1, int y1, int x2, int y2, const TColor& color)
  1339. {
  1340.   SetBkColor(color);
  1341.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &TRect(x1, y1, x2, y2), 0, 0, 0);
  1342. }
  1343.  
  1344. //
  1345. inline bool TDC::TextRect(const TRect& rect, const TColor& color)
  1346. {
  1347.   SetBkColor(color);
  1348.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
  1349. }
  1350.  
  1351. //
  1352. inline bool TDC::FrameRgn(const TRegion& region, const TBrush& brush, const TPoint& p)
  1353. {
  1354.   return ::FrameRgn(GetHDC(), region, brush, p.x, p.y);
  1355. }
  1356.  
  1357. //
  1358. inline bool TDC::FillRgn(const TRegion& region, const TBrush& brush)
  1359. {
  1360.   return ::FillRgn(GetHDC(), region, brush);
  1361. }
  1362.  
  1363. //
  1364. inline bool TDC::InvertRgn(const TRegion& region)
  1365. {
  1366.   return ::InvertRgn(GetHDC(), region);
  1367. }
  1368.  
  1369. //
  1370. inline bool TDC::PaintRgn(const TRegion& region)
  1371. {
  1372.   return ::PaintRgn(GetHDC(), region);
  1373. }
  1374.  
  1375. #if defined(BI_PLAT_WIN32)
  1376. //
  1377. inline bool TDC::AngleArc(int x, int y, uint32 radius, float startAngle, float sweepAngle)
  1378. {
  1379.   return ::AngleArc(GetHDC(), x, y, radius, startAngle, sweepAngle);
  1380. }
  1381.  
  1382. //
  1383. inline bool TDC::AngleArc(const TPoint& Center, uint32 radius, float StartAngle, float SweepAngle)
  1384. {
  1385.   return ::AngleArc(GetHDC(), Center.x, Center.y, radius, StartAngle, SweepAngle);
  1386. }
  1387. #endif
  1388.  
  1389. //
  1390. inline bool TDC::Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  1391. {
  1392.   return ::Arc(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
  1393. }
  1394.  
  1395. //
  1396. inline bool TDC::Arc(const TRect& rect, const TPoint& start, const TPoint& end)
  1397. {
  1398.   return ::Arc(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
  1399. }
  1400.  
  1401. //
  1402. inline bool TDC::Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  1403. {
  1404.   return ::Chord(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
  1405. }
  1406.  
  1407. //
  1408. inline bool TDC::Chord(const TRect& rect, const TPoint& start, const TPoint& end)
  1409. {
  1410.   return ::Chord(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
  1411. }
  1412.  
  1413. //
  1414. inline bool TDC::Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  1415. {
  1416.   return ::Pie(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
  1417. }
  1418.  
  1419. //
  1420. inline bool TDC::Pie(const TRect& rect, const TPoint& start, const TPoint& end)
  1421. {
  1422.   return ::Pie(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
  1423. }
  1424.  
  1425. //
  1426. inline bool TDC::Ellipse(int x1, int y1, int x2, int y2)
  1427. {
  1428.   return ::Ellipse(GetHDC(), x1, y1, x2, y2);
  1429. }
  1430.  
  1431. //
  1432. inline bool TDC::Ellipse(const TPoint& p1, const TPoint& p2)
  1433. {
  1434.   return ::Ellipse(GetHDC(), p1.x, p1.y, p2.x, p2.y);
  1435. }
  1436.  
  1437. //
  1438. inline bool TDC::Ellipse(const TPoint& p, const TSize& s)
  1439. {
  1440.   return ::Ellipse(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy);
  1441. }
  1442.  
  1443. //
  1444. inline bool TDC::Ellipse(const TRect& rect)
  1445. {
  1446.   return ::Ellipse(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  1447. }
  1448.  
  1449. //
  1450. inline bool TDC::LineTo(int x, int y)
  1451. {
  1452.   return ::LineTo(GetHDC(), x, y);
  1453. }
  1454.  
  1455. //
  1456. inline bool TDC::LineTo(const TPoint& point)
  1457. {
  1458.   return ::LineTo(GetHDC(), point.x, point.y);
  1459. }
  1460.  
  1461. //
  1462. inline bool TDC::Polyline(const TPoint* points, int count)
  1463. {
  1464.   return ::Polyline(GetHDC(), points, count);
  1465. }
  1466.  
  1467. //
  1468. inline bool TDC::Polygon(const TPoint* points, int count)
  1469. {
  1470.   return ::Polygon(GetHDC(), (TPoint*)points, count);
  1471. }
  1472.  
  1473. //
  1474. inline bool TDC::PolyPolygon(const TPoint* points, const int* polyCounts, int count)
  1475. {
  1476.   return ::PolyPolygon(GetHDC(), (TPoint*)points, (int*)polyCounts, count); // API typecast
  1477. }
  1478.  
  1479. #if defined(BI_PLAT_WIN32)
  1480. //
  1481. inline bool TDC::PolyPolyline(const TPoint* points, const int* polyCounts, int count)
  1482. {
  1483.   return ::PolyPolyline(GetHDC(), (TPoint*)points, (uint32*)polyCounts, count); // API typecast
  1484. }
  1485.  
  1486. //
  1487. inline bool TDC::PolyBezier(const TPoint* points, int count)
  1488. {
  1489.   return ::PolyBezier(GetHDC(), (TPoint*)points, count);
  1490. }
  1491.  
  1492. //
  1493. inline bool TDC::PolyBezierTo(const TPoint* points, int count)
  1494. {
  1495.   return ::PolyBezierTo(GetHDC(), (TPoint*)points, count);
  1496. }
  1497.  
  1498. //
  1499. inline bool TDC::PolyDraw(const TPoint* points, uint8* types, int count)
  1500. {
  1501.   return ::PolyDraw(GetHDC(), (TPoint*)points, types, count);
  1502. }
  1503.  
  1504. //
  1505. inline bool TDC::PolylineTo(const TPoint* points, int count)
  1506. {
  1507.   return ::PolylineTo(GetHDC(), (TPoint*)points, count);
  1508. }
  1509. #endif
  1510.  
  1511. //
  1512. inline bool TDC::Rectangle(int x1, int y1, int x2, int y2)
  1513. {
  1514.   return ::Rectangle(GetHDC(), x1, y1, x2, y2);
  1515. }
  1516.  
  1517. //
  1518. inline bool TDC::Rectangle(const TPoint& p1, const TPoint& p2)
  1519. {
  1520.   return ::Rectangle(GetHDC(), p1.x, p1.y, p2.x, p2.y);
  1521. }
  1522.  
  1523. //
  1524. inline bool TDC::Rectangle(const TPoint& p, const TSize& s)
  1525. {
  1526.   return ::Rectangle(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy);
  1527. }
  1528.  
  1529. //
  1530. inline bool TDC::Rectangle(const TRect& rect)
  1531. {
  1532.   return ::Rectangle(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  1533. }
  1534.  
  1535. //
  1536. inline bool TDC::RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)
  1537. {
  1538.   return ::RoundRect(GetHDC(), x1, y1, x2, y2, x3, y3);
  1539. }
  1540.  
  1541. //
  1542. inline bool TDC::RoundRect(const TPoint& p1, const TPoint& p2, const TPoint& rad)
  1543. {
  1544.   return ::RoundRect(GetHDC(), p1.x, p1.y, p2.x, p2.y, rad.x, rad.y);
  1545. }
  1546.  
  1547. //
  1548. inline bool TDC::RoundRect(const TPoint& p, const TSize& s, const TPoint& rad)
  1549. {
  1550.   return ::RoundRect(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy, rad.x, rad.y);
  1551. }
  1552.  
  1553. //
  1554. inline bool TDC::RoundRect(const TRect& rect, const TPoint& rad)
  1555. {
  1556.   return ::RoundRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom,
  1557.                      rad.x, rad.y);
  1558. }
  1559.  
  1560. //
  1561. inline TColor TDC::GetPixel(int x, int y) const
  1562. {
  1563.   return ::GetPixel(GetHDC(), x, y);
  1564. }
  1565.  
  1566. //
  1567. inline TColor TDC::GetPixel(const TPoint& point) const
  1568. {
  1569.   return ::GetPixel(GetHDC(), point.x, point.y);
  1570. }
  1571.  
  1572. //
  1573. inline TColor TDC::SetPixel(int x, int y, const TColor& color)
  1574. {
  1575.   return ::SetPixel(GetHDC(), x, y, color);
  1576. }
  1577.  
  1578. //
  1579. inline TColor TDC::SetPixel(const TPoint& point, const TColor& color)
  1580. {
  1581.   return ::SetPixel(GetHDC(), point.x, point.y, color);
  1582. }
  1583.  
  1584. //
  1585. inline bool TDC::BitBlt(int dstX, int dstY, int w, int h, const TDC& srcDC,
  1586.                         int srcX, int srcY, uint32 rop)
  1587. {
  1588.   return ::BitBlt(GetHDC(), dstX, dstY, w, h, srcDC, srcX, srcY, rop);
  1589. }
  1590.  
  1591. //
  1592. inline bool TDC::BitBlt(const TRect& dst, const TDC& srcDC, const TPoint& src,
  1593.                         uint32 rop)
  1594. {
  1595.   return ::BitBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
  1596.                   srcDC, src.x, src.y, rop);
  1597. }
  1598.  
  1599. //
  1600. inline bool TDC::PatBlt(int x, int y, int w, int h, uint32 rop)
  1601. {
  1602.   return ::PatBlt(GetHDC(), x, y, w, h, rop);
  1603. }
  1604.  
  1605. //
  1606. inline bool TDC::PatBlt(const TRect& dst, uint32 rop)
  1607. {
  1608.   return ::PatBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(), rop);
  1609. }
  1610.  
  1611. //
  1612. inline bool TDC::ScrollDC(int dx, int dy, const TRect& scroll, const TRect& clip,
  1613.                           TRegion& updateRgn, TRect& updateRect)
  1614. {
  1615.   return ::ScrollDC(GetHDC(), dx, dy, &scroll, &clip, updateRgn, &updateRect);
  1616. }
  1617.  
  1618. //
  1619. inline bool TDC::ScrollDC(const TPoint& delta, const TRect& scroll, const TRect& clip,
  1620.                           TRegion& updateRgn, TRect& updateRect)
  1621. {
  1622.   return ::ScrollDC(GetHDC(), delta.x, delta.y, &scroll, &clip, updateRgn, &updateRect);
  1623. }
  1624.  
  1625. //
  1626. inline bool TDC::StretchBlt(int dstX, int dstY, int dstW, int dstH,
  1627.                            const TDC& srcDC, int srcX, int srcY, int srcW,
  1628.                            int srcH, uint32 rop)
  1629. {
  1630.   return ::StretchBlt(GetHDC(), dstX, dstY, dstW, dstH,
  1631.                       srcDC, srcX, srcY, srcW, srcH, rop);
  1632. }
  1633.  
  1634. //
  1635. inline bool TDC::StretchBlt(const TRect& dst, const TDC& srcDC,
  1636.                             const TRect& src, uint32 rop)
  1637. {
  1638.   return ::StretchBlt(GetHDC(),
  1639.                       dst.left, dst.top, dst.Width(), dst.Height(),
  1640.                       srcDC, src.left, src.top,
  1641.                       src.Width(), src.Height(), rop);
  1642. }
  1643.  
  1644. #if defined(BI_PLAT_WIN32)
  1645. //
  1646. inline bool TDC::MaskBlt(const TRect& dst,
  1647.                          const TDC& srcDC, const TPoint& src,
  1648.                          const TBitmap& maskBm, const TPoint& maskPos,
  1649.                          uint32 rop)
  1650. {
  1651.   return ::MaskBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
  1652.                    srcDC, src.x, src.y, maskBm, maskPos.x, maskPos.y,
  1653.                    rop);
  1654. }
  1655.  
  1656. //
  1657. inline bool TDC::PlgBlt(const TPoint& dst,
  1658.                         const TDC& srcDC, const TRect& src,
  1659.                         const TBitmap& maskBm, const TPoint& maskPos)
  1660. {
  1661.   return ::PlgBlt(GetHDC(), (TPoint*)&dst,
  1662.                   srcDC, src.left, src.top, src.Width(), src.Height(),
  1663.                   maskBm, maskPos.x, maskPos.y);
  1664. }
  1665. #endif
  1666.  
  1667. //
  1668. inline bool TDC::GetDIBits(const TBitmap& bitmap, uint startScan, uint numScans,
  1669.                            void HUGE* bits, const BITMAPINFO far& info,
  1670.                            uint16 usage)
  1671. {
  1672.   return ::GetDIBits(GetHDC(), bitmap, startScan, numScans, bits,
  1673.                     (BITMAPINFO far*)&info, usage);
  1674. }
  1675.  
  1676. //
  1677. inline bool TDC::GetDIBits(const TBitmap& bitmap, TDib& dib)
  1678. {
  1679.   return ::GetDIBits(GetHDC(), bitmap, dib.StartScan(), dib.NumScans(),
  1680.                      dib.GetBits(), dib.GetInfo(), dib.Usage());
  1681. }
  1682.  
  1683. //
  1684. inline bool TDC::SetDIBits(TBitmap& bitmap, uint startScan, uint numScans,
  1685.                            const void HUGE* bits, const BITMAPINFO far& info,
  1686.                            uint16 usage)
  1687. {
  1688.   return ::SetDIBits(GetHDC(), bitmap, startScan, numScans,
  1689.                      bits, (BITMAPINFO far*)&info, usage);
  1690.                      // API typecast
  1691. }
  1692.  
  1693. //
  1694. inline bool TDC::SetDIBits(TBitmap& bitmap, const TDib& dib)
  1695. {
  1696.   return ::SetDIBits(GetHDC(), bitmap, dib.StartScan(), dib.NumScans(),
  1697.                      dib.GetBits(), (BITMAPINFO far*)dib.GetInfo(), dib.Usage());
  1698.                                    // API typecast
  1699. }
  1700.  
  1701. //
  1702. inline bool TDC::SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  1703.                                    uint startScan, uint numScans,
  1704.                                    const void HUGE* bits,
  1705.                                    const BITMAPINFO far& info, uint16 usage)
  1706. {
  1707.   return ::SetDIBitsToDevice(
  1708.              GetHDC(), dst.left, dst.top,
  1709.              dst.Width(), dst.Height(), src.x, src.y,
  1710.              startScan, numScans,
  1711.              (void HUGE*)bits, (BITMAPINFO far*)&info, usage
  1712.          );                  // API typecast
  1713. }
  1714.  
  1715. //
  1716. inline bool TDC::SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  1717.                                    const TDib& dib)
  1718. {
  1719.   return ::SetDIBitsToDevice(
  1720.              GetHDC(),
  1721.              dst.left, dst.top, dst.Width(), dst.Height(),
  1722.              src.x, src.y,
  1723.              dib.StartScan(), dib.NumScans(),
  1724.              (void HUGE*)dib.GetBits(),
  1725.              (BITMAPINFO far*)dib.GetInfo(), dib.Usage()
  1726.          );                  // API typecast
  1727. }
  1728.  
  1729. //
  1730. inline bool TDC::StretchDIBits(const TRect& dst, const TRect& src,
  1731.                                const void HUGE* bits,
  1732.                                const BITMAPINFO far& info,
  1733.                                uint16 usage, uint32 rop)
  1734. {
  1735.   return ::StretchDIBits(
  1736.              GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
  1737.              src.left, src.top, src.Width(), src.Height(),
  1738.              bits, (BITMAPINFO far*)&info, usage, rop
  1739.          );
  1740.          // API typecast
  1741. }
  1742.  
  1743. //
  1744. inline bool TDC::StretchDIBits(const TRect& dst, const TRect& src,
  1745.                                const TDib& dib, uint32 rop)
  1746. {
  1747.   return ::StretchDIBits(
  1748.              GetHDC(),
  1749.              dst.left, dst.top, dst.Width(), dst.Height(),
  1750.              src.left, src.top, src.Width(), src.Height(),
  1751.              dib.GetBits(),
  1752.              (BITMAPINFO far*)dib.GetInfo(),
  1753.              dib.Usage(), rop
  1754.          );
  1755.              // API typecast
  1756. }
  1757.  
  1758. #if defined(BI_PLAT_WIN32)
  1759. //
  1760. // Create a fast DIB under Win32.
  1761. //
  1762. inline HBITMAP TDC::CreateDIBSection(const BITMAPINFO& info, uint usage, void** bits, HANDLE section, uint32 offset)
  1763. {
  1764.   return ::CreateDIBSection(GetHDC(), &info, usage, bits, section, offset);
  1765. }
  1766. #endif
  1767.  
  1768. //
  1769. inline bool TDC::FloodFill(const TPoint& point, const TColor& color)
  1770. {
  1771.   return ::FloodFill(GetHDC(), point.x, point.y, color);
  1772. }
  1773.  
  1774. //
  1775. inline bool TDC::ExtFloodFill(const TPoint& point, const TColor& color, uint16 fillType)
  1776. {
  1777.   return ::ExtFloodFill(GetHDC(), point.x, point.y, color, fillType);
  1778. }
  1779.  
  1780. //
  1781. inline bool TDC::TextOut(const TPoint& p, const char far* str, int count)
  1782. {
  1783.   return TextOut(p.x, p.y, str, count);
  1784. }
  1785.  
  1786. //
  1787. inline bool TDC::ExtTextOut(const TPoint& p, uint16 options, const TRect* rect,
  1788.                             const char far* str, int count, const int far* dx)
  1789. {
  1790.   return ExtTextOut(p.x, p.y, options, rect, str, count, dx);
  1791. }
  1792.  
  1793. //
  1794. inline bool TDC::TabbedTextOut(const TPoint& p, const char far* str, int count,
  1795.                                int numPositions, const int far* positions,
  1796.                                int tabOrigin)
  1797. {
  1798.   TSize size;
  1799.   TabbedTextOut(p, str, count, numPositions, positions, tabOrigin, size);
  1800.   return true;
  1801. }
  1802.  
  1803. //
  1804. inline bool TDC::GetTextExtent(const char far* str, int stringLen, TSize& size)
  1805. {
  1806.   return ::GetTextExtentPoint(GetAttributeHDC(), str, stringLen, &size);
  1807. }
  1808.  
  1809. //
  1810. inline TSize TDC::GetTextExtent(const char far* str, int stringLen)
  1811. {
  1812. #if defined(BI_PLAT_WIN32)
  1813.   TSize size;
  1814.   ::GetTextExtentPoint(GetAttributeHDC(), str, stringLen, &size);
  1815.   return size;
  1816. #else
  1817.   return ::GetTextExtent(GetAttributeHDC(), str, stringLen);
  1818. #endif
  1819. }
  1820.  
  1821. //
  1822. inline bool TDC::GetTabbedTextExtent(const char far* str, int strLen,
  1823.                                      int numPositions, const int far* positions,
  1824.                                      TSize& size) const
  1825. {
  1826.   size = ::GetTabbedTextExtent(GetAttributeHDC(), str, strLen, numPositions,
  1827.                                (int far*)positions);   // API Typecast
  1828.   return true;
  1829. }
  1830.  
  1831. //
  1832. inline TSize TDC::GetTabbedTextExtent(const char far* str, int strLen,
  1833.                                       int numPositions,
  1834.                                       const int far* positions) const
  1835. {
  1836.   return ::GetTabbedTextExtent(GetAttributeHDC(), str, strLen, numPositions,
  1837.                                (int far*)positions);   // API Typecast
  1838. }
  1839.  
  1840. //
  1841. inline uint TDC::GetTextAlign() const
  1842. {
  1843.   return ::GetTextAlign(GetAttributeHDC());
  1844. }
  1845.  
  1846. //
  1847. inline uint TDC::SetTextAlign(uint flags)
  1848. {
  1849.   if (GetHDC() != GetAttributeHDC())
  1850.     ::SetTextAlign(GetHDC(), flags);
  1851.   return ::SetTextAlign(GetAttributeHDC(), flags);
  1852. }
  1853.  
  1854. //
  1855. inline int TDC::GetTextCharacterExtra() const
  1856. {
  1857.   return ::GetTextCharacterExtra(GetAttributeHDC());
  1858. }
  1859.  
  1860. //
  1861. inline int TDC::SetTextCharacterExtra(int extra)
  1862. {
  1863.   if (GetHDC() != GetAttributeHDC())
  1864.     ::SetTextCharacterExtra(GetHDC(), extra);
  1865.   return ::SetTextCharacterExtra(GetAttributeHDC(), extra);
  1866. }
  1867.  
  1868. //
  1869. inline bool TDC::SetTextJustification(int breakExtra, int breakCount)
  1870. {
  1871.   return ::SetTextJustification(GetAttributeHDC(), breakExtra, breakCount);
  1872. }
  1873.  
  1874. //
  1875. inline int TDC::GetTextFace(int count, char far* facename) const
  1876. {
  1877.   return ::GetTextFace(GetAttributeHDC(), count, facename);
  1878. }
  1879.  
  1880. //
  1881. inline bool TDC::GetTextMetrics(TEXTMETRIC far& metrics) const
  1882. {
  1883.   return ::GetTextMetrics(GetAttributeHDC(), &metrics);
  1884. }
  1885.  
  1886. //
  1887. inline uint32 TDC::GetGlyphOutline(uint chr, uint format, GLYPHMETRICS far& gm,
  1888.                                   uint32 buffSize, void far* buffer,
  1889.                                   const MAT2 far& mat2)
  1890. {
  1891.   return ::GetGlyphOutline(GetAttributeHDC(), chr, format, &gm, buffSize,
  1892.                            buffer, (MAT2*)&mat2);
  1893. }
  1894.  
  1895. //
  1896. inline int TDC::GetKerningPairs(int pairs, KERNINGPAIR far* krnPair)
  1897. {
  1898.   return ::GetKerningPairs(GetAttributeHDC(), pairs, krnPair);
  1899. }
  1900.  
  1901. //
  1902. inline uint
  1903. TDC::GetOutlineTextMetrics(uint data, OUTLINETEXTMETRIC far& otm)
  1904. {
  1905.   return ::GetOutlineTextMetrics(GetAttributeHDC(), data, &otm);
  1906. }
  1907.  
  1908. //
  1909. inline bool TDC::GetCharWidth(uint firstChar, uint lastChar, int* buffer)
  1910. {
  1911.   return ::GetCharWidth(GetAttributeHDC(), firstChar, lastChar, buffer);
  1912. }
  1913.  
  1914. //
  1915. inline uint32 TDC::SetMapperFlags(uint32 flag)
  1916. {
  1917.   if (GetHDC() != GetAttributeHDC())
  1918.     ::SetMapperFlags(GetHDC(), flag);
  1919.   return ::SetMapperFlags(GetAttributeHDC(), flag);
  1920. }
  1921.  
  1922. //
  1923. inline bool TDC::GetAspectRatioFilter(TSize& size) const
  1924. {
  1925.   return ::GetAspectRatioFilterEx(GetAttributeHDC(), &size);
  1926. }
  1927.  
  1928. //
  1929. inline int TDC::EnumFonts(const char far* faceName, OLDFONTENUMPROC callback, void far* data) const
  1930. {
  1931.   return ::EnumFonts(GetAttributeHDC(), faceName, callback, LPARAM(data));
  1932. }
  1933.  
  1934. //
  1935. inline bool TDC::GetCharABCWidths(uint firstChar, uint lastChar, ABC* abc)
  1936. {
  1937.   return ::GetCharABCWidths(GetAttributeHDC(), firstChar, lastChar, abc);
  1938. }
  1939.  
  1940. //
  1941. inline int TDC::EnumFontFamilies(const char far* familyName, FONTENUMPROC callback, void far* data) const
  1942. {
  1943.   return ::EnumFontFamilies(GetAttributeHDC(), familyName, callback, LPARAM(data));
  1944. }
  1945.  
  1946. //
  1947. inline uint32 TDC::GetFontData(uint32 table, uint32 offset, void* buffer, long data)
  1948. {
  1949.   return ::GetFontData(GetAttributeHDC(), table, offset, buffer, data);
  1950. }
  1951.  
  1952. #if defined(BI_PLAT_WIN32)
  1953. //
  1954. inline bool TDC::BeginPath()
  1955. {
  1956.   return ::BeginPath(GetHDC());
  1957. }
  1958.  
  1959. //
  1960. inline bool TDC::CloseFigure()
  1961. {
  1962.   return ::CloseFigure(GetHDC());
  1963. }
  1964.  
  1965. //
  1966. inline bool TDC::EndPath()
  1967. {
  1968.   return ::EndPath(GetHDC());
  1969. }
  1970.  
  1971. //
  1972. inline bool TDC::FlattenPath()
  1973. {
  1974.   return ::FlattenPath(GetHDC());
  1975. }
  1976.  
  1977. //
  1978. inline bool TDC::WidenPath()
  1979. {
  1980.   return ::WidenPath(GetHDC());
  1981. }
  1982.  
  1983. //
  1984. inline bool TDC::FillPath()
  1985. {
  1986.   return ::FillPath(GetHDC());
  1987. }
  1988.  
  1989. //
  1990. inline bool TDC::StrokePath()
  1991. {
  1992.   return ::StrokePath(GetHDC());
  1993. }
  1994.  
  1995. //
  1996. inline bool TDC::StrokeAndFillPath()
  1997. {
  1998.   return ::StrokeAndFillPath(GetHDC());
  1999. }
  2000.  
  2001. //
  2002. inline bool TDC::SelectClipPath(int mode)
  2003. {
  2004.   return ::SelectClipPath(GetHDC(), mode);
  2005. }
  2006.  
  2007. //
  2008. inline HRGN TDC::PathToRegion()
  2009. {
  2010.   return ::PathToRegion(GetHDC());
  2011. }
  2012. #endif
  2013.  
  2014. //
  2015. inline void TMemoryDC::SelectObject(const TBrush& brush)
  2016. {
  2017.   TDC::SelectObject(brush);
  2018. }
  2019.  
  2020. //
  2021. inline void TMemoryDC::SelectObject(const TPen& pen)
  2022. {
  2023.   TDC::SelectObject(pen);
  2024. }
  2025.  
  2026. //
  2027. inline void TMemoryDC::SelectObject(const TFont& font)
  2028. {
  2029.   TDC::SelectObject(font);
  2030. }
  2031.  
  2032. //
  2033. inline void TMemoryDC::SelectObject(const TPalette& palette,
  2034.                                     bool forceBackground)
  2035. {
  2036.   TDC::SelectObject(palette, forceBackground);
  2037. }
  2038.  
  2039. //
  2040. inline void TMemoryDC::RestoreObjects()
  2041. {
  2042.   TDC::RestoreObjects();
  2043.   RestoreBitmap();
  2044. }
  2045.  
  2046. //
  2047. inline HMETAFILE TMetaFileDC::Close()
  2048. {
  2049.   HMETAFILE mf = ::CloseMetaFile(GetHDC());
  2050.   Handle = 0;
  2051.   return mf;
  2052. }
  2053.  
  2054. //
  2055. // Returns true if the device context contains an enhanced metafile.
  2056. //
  2057. inline bool TMetaFileDC::IsEnhanced() const
  2058. {
  2059.   return Enhanced;
  2060. }
  2061.  
  2062. #if defined(BI_PLAT_WIN32)
  2063. //
  2064. // Closes the enhanced metafile DC.
  2065. //
  2066. inline HENHMETAFILE TMetaFileDC::CloseEnh()
  2067. {
  2068.   HENHMETAFILE emf = ::CloseEnhMetaFile(GetHDC());
  2069.   Handle = 0;
  2070.   return emf;
  2071. }
  2072.  
  2073. //
  2074. // Insert a comment record into the enhanced metafile.
  2075. //
  2076. inline bool TMetaFileDC::Comment(uint bytes, const void* data) {
  2077.   if (IsEnhanced()) {
  2078.     return ::GdiComment(GetHDC(), bytes, (const BYTE*)data);
  2079.   }
  2080.   return false;
  2081. }
  2082.  
  2083. #endif
  2084.  
  2085. #if !defined(BI_PLAT_WIN32) && !defined(OWL_WING_H)
  2086. # include <owl/wing.h>
  2087. #endif
  2088.  
  2089. //
  2090. // Return the DOCINFO structure.
  2091. //
  2092. inline DOCINFO& TPrintDC::GetDocInfo()
  2093. {
  2094.   return DocInfo;
  2095. }
  2096.  
  2097. //
  2098. // Sets the DOCINFO structure.
  2099. //
  2100. inline void TPrintDC::SetDocInfo(const DOCINFO& docinfo)
  2101. {
  2102.   DocInfo = docinfo;
  2103. }
  2104.  
  2105. //
  2106. inline int TPrintDC::Escape(int esc, int count, const void* inData, void* outData)
  2107. {
  2108.   return ::Escape(GetHDC(), esc, count, (const char far*)inData, outData);
  2109.                                         // API type cast
  2110. }
  2111.  
  2112. //
  2113. inline int TPrintDC::SetAbortProc(ABORTPROC proc)
  2114. {
  2115.   return ::SetAbortProc(GetHDC(), proc);
  2116. }
  2117.  
  2118. //
  2119. inline int TPrintDC::StartDoc(const char far* docName, const char far* output)
  2120. {
  2121.   DocInfo.lpszDocName = (char far*)docName;
  2122.   DocInfo.lpszOutput = (char far*)output;
  2123.   return ::StartDoc(GetHDC(), &DocInfo);
  2124. }
  2125.  
  2126. //
  2127. inline int TPrintDC::StartPage()
  2128. {
  2129.   // Only call if not banding
  2130.   return ::StartPage(GetHDC());
  2131. }
  2132.  
  2133. //
  2134. inline int TPrintDC::BandInfo(TBandInfo& bandInfo)
  2135. {
  2136.   return Escape(BANDINFO, sizeof(TBandInfo), 0, (LPSTR)&bandInfo);
  2137. }
  2138.  
  2139. //
  2140. inline int TPrintDC::NextBand(TRect& rect)
  2141. {
  2142.   return Escape(NEXTBAND, 0, 0, (void*)&rect);
  2143. }
  2144.  
  2145. //
  2146. inline int TPrintDC::EndPage()
  2147. {
  2148.   // Only call if not banding
  2149.   RestoreObjects();  // Make sure this TDC stays in sync with HDC
  2150.   return ::EndPage(GetHDC());
  2151. }
  2152.  
  2153. //
  2154. inline int TPrintDC::AbortDoc()
  2155. {
  2156.   return ::AbortDoc(GetHDC());
  2157. }
  2158.  
  2159. //
  2160. inline int TPrintDC::EndDoc()
  2161. {
  2162.   return ::EndDoc(GetHDC());
  2163. }
  2164.  
  2165. #if defined(BI_PLAT_WIN16)
  2166. //
  2167. inline bool TPrintDC::QueryAbort(int rsvd)
  2168. {
  2169.   return ::QueryAbort(GetHDC(), rsvd);
  2170. }
  2171. #endif
  2172.  
  2173. //
  2174. inline uint TPrintDC::QueryEscSupport(int escapeNum)
  2175. {
  2176.   return Escape(QUERYESCSUPPORT, sizeof(int), &escapeNum);
  2177. }
  2178.  
  2179. //
  2180. inline int TPrintDC::SetCopyCount(int reqestCopies, int& actualCopies)
  2181. {
  2182.   return Escape(SETCOPYCOUNT, sizeof(int), &reqestCopies, &actualCopies);
  2183. }
  2184.  
  2185. #endif  // OWL_DC_H
  2186.